<template>
  <div>
    <div class="nav">
      <h1>cnode js</h1>
      <input type="text" placeholder="🔍" />
      <div class="box">
        <div>首页</div>
        <div>新手入门</div>
        <div>API</div>
        <div>关于</div>
        <div>注册</div>
        <div>登录</div>
      </div>
    </div>
    <div class="box1" @scroll="togg">
      <div class="box2">
        <div class="nav-con">
          <van-tabs type="card">
            <van-tab title="全部">
              <div class="con" v-for="item in list" :key="item">
                <div class="q1"></div>
                <p>{{ item.title }}</p>
              </div>
            </van-tab>
            <van-tab title="精华">
              <div class="con" v-for="item in list1" :key="item">
                <div class="q1"></div>
                <p>{{ item.title }}</p>
              </div>
            </van-tab>
            <van-tab title="分享">
              <div class="con" v-for="item in list2" :key="item">
                <div class="q1"></div>
                <p>{{ item.title }}</p>
              </div></van-tab
            >
            <van-tab title="问答">问答</van-tab>
            <van-tab title="招聘">招聘</van-tab>
            <van-tab title="客户端测试">客户端测试</van-tab>
          </van-tabs>
        </div>
      </div>
    </div>
    <div class="fan iconfont icon-fanhuidingbu" @click="fanhui"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      list1: [],
      list2: [],
    };
  },
  methods: {
    togg(e) {
      console.log(e.target.scrollTop);
    },
    fanhui() {
      var box1 = document.getElementsByClassName("box1")[0];
      setTimeout(() => {
        box1.scrollTop = 900;
      }, 1000);
      setTimeout(() => {
        box1.scrollTop = 400;
      }, 2000);
      setTimeout(() => {
        box1.scrollTop = 0;
      }, 3000);
    },
  },
  mounted() {
    this.$axios.get("https://cnodejs.org/api/v1/topics ").then((res) => {
      this.list = res.data.data;
      this.list1 = this.list.splice(10, 10);
      this.list2 = this.list.splice(20, 10);
    });
  },
};
</script>
<style scoped>
* {
  margin: 0;
  padding: 0;
}
.nav {
  width: 100%;
  height: 180px;
  background: rgba(0, 0, 0, 0.816);
  position: fixed;
  top: 0px;
  left: 0px;
  z-index: 9999;
}
h1 {
  padding: 20px;
  font-size: 38px;
  color: #fff;
}
input {
  margin: -10px 20px;
  background: lightcyan;
  border: none;
  height: 30px;
  border-radius: 15px 15px 15px 15px;
  padding-left: 20px;
}
.box {
  width: 100%;
  height: 50px;
  color: lightgoldenrodyellow;
  display: flex;
  margin-top: 18px;
  justify-content: space-around;
  align-items: center;
}
.nav-con {
  width: 100%;
  margin-top: 180px;
  padding-top: 20px;
}
.con {
  width: 100%;
  height: 60px;
  margin-top: 10px;
  background: lightyellow;
}
.q1 {
  width: 50px;
  height: 50px;
  background: aquamarine;
}
p {
  float: left;
  margin: -30px 60px;
}
.box1 {
  width: 100%;
  height: 730px;
  overflow-y: auto;
}
.box2 {
  width: 100%;
  height: 200vh;
}
.fan {
  width: 60px;
  height: 60px;
  border-radius: 100%;
  position: fixed;
  bottom: 10px;
  right: 10px;
  font-size: 56px;
  color: red;
}
</style>